#-*- coding: iso-8859-1 -*-
from Tkinter import *
import ToolTip

class CadreActions(object):
    def __init__(self,ref):
        dimBouton = 40
        self.actions = Frame(ref, height=80,width=160, bg = "black", relief = RIDGE, borderwidth = 5)
        self.actions.place(x=30,y=90)
        self.bouton0_0 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton0_1 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton0_2 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton0_3 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton1_0 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton1_1 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton1_2 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton1_3 = Canvas(self.actions, height = dimBouton, width = dimBouton, bg = "black", relief=RAISED, borderwidth = 4)
        self.bouton0_0.grid(row=0,column=0)
        self.bouton0_1.grid(row=0,column=1)
        self.bouton0_2.grid(row=0,column=2)
        self.bouton0_3.grid(row=0,column=3)
        self.bouton1_0.grid(row=1,column=0)
        self.bouton1_1.grid(row=1,column=1)
        self.bouton1_2.grid(row=1,column=2)
        self.bouton1_3.grid(row=1,column=3)


    def bindAction(self, bouton, piton, fonction):
        self.bouton.bind(piton, fonction)
        
    def setIcone(self, bouton, icone,tooltip):
        if bouton == 0:
            self.bouton0_0.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton0_0, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 1:
            self.bouton0_1.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton0_1, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 2:
            self.bouton0_2.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton0_2, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 3:
            self.bouton0_3.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton0_3, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 4:
            self.bouton1_0.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton1_0, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 5:
            self.bouton1_1.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton1_1, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 6:
            self.bouton1_2.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton1_2, text=tooltip, follow_mouse=1, delay=200)
        if bouton == 7:
            self.bouton1_3.create_image(3,3,image= icone, anchor =NW)
            ToolTip.ToolTip(self.bouton1_3, text=tooltip, follow_mouse=1, delay=200)
        
            
        self.bouton0_0.grid(row=0,column=0)
        self.bouton0_1.grid(row=0,column=1)
        self.bouton0_2.grid(row=0,column=2)
        self.bouton0_3.grid(row=0,column=3)
        self.bouton1_0.grid(row=1,column=0)
        self.bouton1_1.grid(row=1,column=1)
        self.bouton1_2.grid(row=1,column=2)
        self.bouton1_3.grid(row=1,column=3)
    